#ifndef __MODULEMGRFORUSER_H
#define __MODULEMGRFORUSER_H

#include "../hle.h"
#include "../loaders.h"

typedef struct
{
    SceSize size;
    SceUID  mpidstack;
    SceSize stacksize;
    s32     priority;
    u32     attribute;
} SceKernelSMOption;

typedef struct
{
    SceSize size;
    u8      nsegment;
    u8      reserved[3];
    u32     segmentaddr[4];
    u32     segmentsize[4];
    u32     entry_addr;
    u32     gp_value;
    u32     text_addr;
    u32     text_size;
    u32     data_size;
    u32     bss_size;
    u16     attribute;
    u8      version[2];
    char    name[28];
    u8      encrypted;
} Module;

u32 __KernelGetModuleGP(SceUID module);
SceUID __KernelLoadELFFromPtr(Module *m, const char *ptr, s32 loadAddress);
SceUID __KernelLoadELF(Module *m, const char *filename, s32 loadAddress);
SceUID __KernelLoadELFFromHandle(Module *m, u32 handle, s32 loadAddress);
LoadResult __KernelLoadExec(const char *filename);
LoadResult __KernelLoadExecFromPtr(const char *ptr, const char *filename);
SceUID __KernelGetCurModuleId();
void __KernelStartModule(SceUID uid, s32 args, const char *argp, SceKernelSMOption *options);
void __KernelSetDefaultSMOption(SceKernelSMOption *option);

#endif

